#include <i86.h>
#include <stdio.h>

#include "keyboard.h"


#pragma aux get_flags = \
    "mov eax, 0h" \
    "mov ah, 01h" \
    "int 16h" \
    "pushfd" \
    "pop ebx" \
    modify [ebx] value [ebx];


#pragma aux get_key = \
    "mov eax, 0h" \
    "int 16h" \
    modify [eax] value [al];

int poll_keyboard(char* key)
{
    union REGS regs;
    int flags;

    flags = get_flags() & (1<<6);

    if ( flags == 0 )
        *key = get_key();
    
    return flags;
}

